OleAutoArgs Values

Sorry for the second post on this topic but I am still stuck with this issue.

I would like to read the values put into the autoArg variable. I believe it will help me trouble shoot my complicated program. Can anyone help me read and print these values as the program runs?

Here is a sample of what would help (if it worked).

OleAutoArgs args = create
put (args, "one")
put (args, 2)
put (args, 3.3)

// How do i read the arg values?????
// this does not work. any Ideas on how to do this?
for each arg in args do{
    print string of(arg)
}

Is there a way to read the arg value?

Sorry for the second post. I really need a usable answer. This question was also asked in

https://www.ibm.com/developerworks/community/forums/html/topic?id=0b7514d8-5b21-479b-ba78-276e4d765594

Thank you,

David


tlhIngan - Thu Jun 23 11:36:02 EDT 2016

Re: OleAutoArgs Values
Mathias Mamsch - Thu Jun 23 16:05:24 EDT 2016

You need to make a library that "hooks" the autoargs ... like this (i did not run the code nor check for syntax errors, just as a quick answer). 

Put the following into an include file (fix the errors). Include the include file at the TOP of your script (before any calls to OLE functions). It should allow you to do the following: 

for sVal in getArgs  myOleAutoArgs do print sVal "\n"

Hope that gives you an idea on how to do something like this. Regards, Mathias

 

// OLEDebug.inc 
​// create functions for accessing the original put functions after we 'override' them below
void oldput (OleAutoArgs a, int x) { put (a, x); }
void oldput (OleAutoArgs a, char x) { put (a, x); }
void oldput (OleAutoArgs a, bool x) { put (a, x); }
void oldput (OleAutoArgs a, string x) { put (a, x); }
void oldput (OleAutoArgs a, OleAutoObj x) { put (a, x); }

void oldput (OleAutoArgs a, string n, int x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, OleAutoObj x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, char x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, bool x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, string x) { put (a, n, x); }


// void oldDelete ... you might want to hook delete(OleAutoArgs) to clear 
// the stored values from the skip list. 

// This is the big skip where we store all parameters in. Might want to optimize ;-)
Skip oleArgs = createString(); 

// stores the string value in the big skip
void registerArg (OleAutoArgs args, string value) {
     int cnt = 0; 
     string skey = (ref args) "_"; 

     find (oleArgs, skey , cnt); // get the currently stored number of arguments
     put(oleArgs, skey cnt "", value, true); // store the arguments

     put(oleArgs, skey cnt "", cnt+1, true);  // store the argument count
}

Skip skoleIter = create(); 

Skip getArgs (OleAutoArgs args) {
   setempty(skoleIter); 
   int cnt = 0; 
   string key = (ref args) "_"; 
   find (oleArgs, key, cnt); 
   for (i = 0; i < cnt; i++) {
        string sVal = null; 
        if (find(oleArgs, key i "", sVal)) put (skoleIter, i, sVal); 
   }
   return skoleIter; 
}



string ref(OleAutoArgs a) {
    return ((addr_ a) int) ""; 
}

// Hook the put functions to save the args before calling the old function
void put (OleAutoArgs a, int x)  { registerArg(a, x ""); oldput (a, x); }
void put (OleAutoArgs a, char x) { registerArg(a, x ""); oldput (a, x);
void put (OleAutoArgs a, bool x) { registerArg(a, x ""); oldput (a, x); }
void put (OleAutoArgs a, string x) { registerArg(a, x "");  oldput (a, x); }
void put (OleAutoArgs a, OleAutoObj x) { registerArg(a, ref x);  oldput (a, x); }

void put (OleAutoArgs a, string n, int x) { registerArg(a, x "");  oldput (a, n, x); }
void put (OleAutoArgs a, string n, OleAutoObj x) { registerArg(a, ref x);  oldput (a, n, x); }
void put (OleAutoArgs a, string n, char x) { registerArg(a, x "");  oldput (a, n, x); }
void put (OleAutoArgs a, string n, bool x) { registerArg(a, x "");  oldput (a, n, x); }
void put (OleAutoArgs a, string n, string x) { registerArg(a, x "");  oldput (a, n, x); }

Re: OleAutoArgs Values
tlhIngan - Thu Jun 23 18:00:48 EDT 2016

Mathias Mamsch - Thu Jun 23 16:05:24 EDT 2016

You need to make a library that "hooks" the autoargs ... like this (i did not run the code nor check for syntax errors, just as a quick answer). 

Put the following into an include file (fix the errors). Include the include file at the TOP of your script (before any calls to OLE functions). It should allow you to do the following: 

for sVal in getArgs  myOleAutoArgs do print sVal "\n"

Hope that gives you an idea on how to do something like this. Regards, Mathias

 

// OLEDebug.inc 
​// create functions for accessing the original put functions after we 'override' them below
void oldput (OleAutoArgs a, int x) { put (a, x); }
void oldput (OleAutoArgs a, char x) { put (a, x); }
void oldput (OleAutoArgs a, bool x) { put (a, x); }
void oldput (OleAutoArgs a, string x) { put (a, x); }
void oldput (OleAutoArgs a, OleAutoObj x) { put (a, x); }

void oldput (OleAutoArgs a, string n, int x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, OleAutoObj x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, char x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, bool x) { put (a, n, x); }
void oldput (OleAutoArgs a, string n, string x) { put (a, n, x); }


// void oldDelete ... you might want to hook delete(OleAutoArgs) to clear 
// the stored values from the skip list. 

// This is the big skip where we store all parameters in. Might want to optimize ;-)
Skip oleArgs = createString(); 

// stores the string value in the big skip
void registerArg (OleAutoArgs args, string value) {
     int cnt = 0; 
     string skey = (ref args) "_"; 

     find (oleArgs, skey , cnt); // get the currently stored number of arguments
     put(oleArgs, skey cnt "", value, true); // store the arguments

     put(oleArgs, skey cnt "", cnt+1, true);  // store the argument count
}

Skip skoleIter = create(); 

Skip getArgs (OleAutoArgs args) {
   setempty(skoleIter); 
   int cnt = 0; 
   string key = (ref args) "_"; 
   find (oleArgs, key, cnt); 
   for (i = 0; i < cnt; i++) {
        string sVal = null; 
        if (find(oleArgs, key i "", sVal)) put (skoleIter, i, sVal); 
   }
   return skoleIter; 
}



string ref(OleAutoArgs a) {
    return ((addr_ a) int) ""; 
}

// Hook the put functions to save the args before calling the old function
void put (OleAutoArgs a, int x)  { registerArg(a, x ""); oldput (a, x); }
void put (OleAutoArgs a, char x) { registerArg(a, x ""); oldput (a, x);
void put (OleAutoArgs a, bool x) { registerArg(a, x ""); oldput (a, x); }
void put (OleAutoArgs a, string x) { registerArg(a, x "");  oldput (a, x); }
void put (OleAutoArgs a, OleAutoObj x) { registerArg(a, ref x);  oldput (a, x); }

void put (OleAutoArgs a, string n, int x) { registerArg(a, x "");  oldput (a, n, x); }
void put (OleAutoArgs a, string n, OleAutoObj x) { registerArg(a, ref x);  oldput (a, n, x); }
void put (OleAutoArgs a, string n, char x) { registerArg(a, x "");  oldput (a, n, x); }
void put (OleAutoArgs a, string n, bool x) { registerArg(a, x "");  oldput (a, n, x); }
void put (OleAutoArgs a, string n, string x) { registerArg(a, x "");  oldput (a, n, x); }

Mathias,

   The Hook method will work fine. Is there a reason IBM does not expose the OleAutoArg so we can simply look inside? It must be stored in memory somewhere?

 

Thanks for the leg up on this!!!!!!

-David